home *** CD-ROM | disk | FTP | other *** search
- class SecretCodeInterface extends sarbakan.visual.element.DynamicElement
- {
- var mc;
- static var SECRET_CODES = {RANDOM_WAFFLES:"sun",BONUS_LEVEL:"pow",SYRUP_WATER:"find",RESET:"reset"};
- function SecretCodeInterface(l_mc)
- {
- super("secretCode");
- this.setMC(l_mc);
- }
- function show()
- {
- this.setState("open");
- }
- function open()
- {
- if(this.stateFinished())
- {
- this.setState("idle");
- }
- }
- function idle()
- {
- if(this.stateStarting())
- {
- this.initButtons();
- }
- if(Key.isDown(13))
- {
- this.onButtonValidate();
- }
- }
- function good()
- {
- if(this.stateFinished())
- {
- this.setState("close");
- }
- }
- function bad()
- {
- if(this.stateFinished())
- {
- this.setState("idle");
- }
- }
- function close()
- {
- if(this.stateFinished())
- {
- this.disable();
- }
- }
- function onButtonValidate()
- {
- _global.C.oPackaging.clickSound();
- this.validateCode();
- }
- function onButtonBack()
- {
- _global.C.oPackaging.clickSound();
- this.setState("close");
- }
- function initButtons()
- {
- this.mc.state.btValidate.onRelease = sarbakan.utils.Delegate.create(this,this.onButtonValidate);
- this.mc.state.btBack.onRelease = sarbakan.utils.Delegate.create(this,this.onButtonBack);
- }
- function validateCode()
- {
- var _loc3_ = false;
- for(var _loc4_ in SecretCodeInterface.SECRET_CODES)
- {
- if(this.mc.state.code.text.toLowerCase() == SecretCodeInterface.SECRET_CODES[_loc4_])
- {
- _global.C.unlockCode(_loc4_);
- _loc3_ = true;
- this.setState("good");
- getURL("javascript:trackEvent(\'" + SecretCodeInterface.SECRET_CODES[_loc4_] + "\');","");
- break;
- }
- }
- if(!_loc3_)
- {
- this.setState("bad");
- }
- }
- }
-